package com.wjs.spring.bean;

import org.springframework.beans.factory.FactoryBean;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DateFactoryBean implements FactoryBean {
    private String date;

    public DateFactoryBean(){}

    public DateFactoryBean(String date) {
        this.date = date;
    }

    @Override
    public boolean isSingleton() {
        return true;
    }

    @Override
    public Object getObject() throws Exception {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        Date parse = sdf.parse(date);
        return parse;
    }

    @Override
    public Class<?> getObjectType() {
        return null;
    }
}
